home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / text / hyper / hsc_source.lha / hsc / source / ugly / args_fre.c < prev    next >
C/C++ Source or Header  |  1996-11-15  |  2KB  |  92 lines

  1. /*
  2.  * ugly/args_fre.c
  3.  *
  4.  * ugly argument freeing functions
  5.  * sub-module for ugly/args.c
  6.  *
  7.  * Copyright (C) 1994,95,96  Thomas Aglassinger
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  *
  23.  * updated: 15-Nov-1996
  24.  * created:  3-Jul-1994
  25.  *
  26.  */
  27.  
  28. /*
  29.  * includes
  30.  */
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <stdarg.h>
  34. #include <string.h>
  35. #include <ctype.h>
  36.  
  37. #include "utypes.h"
  38. #include "umemory.h"
  39. #include "ustring.h"
  40. #include "dllist.h"
  41.  
  42. #include "uargs.h"
  43.  
  44. /*
  45.  * del_arginfo
  46.  *   ( called by _free_args() )
  47.  *
  48.  */
  49. void del_arginfo(APTR data)
  50. {
  51.  
  52.     struct arginfo *arg = (struct arginfo *) data;
  53.  
  54.     if (arg)
  55.     {
  56.  
  57.         /* type dependent cleanup */
  58.         if (arg->ai_type == ARG_ENUM)
  59.             ufreestr(arg->ai_misc1.ai_enum);
  60.  
  61.         /* cleanup entities */
  62.         ufreestr(arg->ai_id);
  63.         ufreestr(arg->ai_help);
  64.         arg->ai_type = 0;
  65.         arg->ai_dest = NULL;
  66.         arg->ai_func = NULL;
  67.  
  68.         /* cleanup whole structure */
  69.         ufree(arg);
  70.  
  71.     }
  72.  
  73. }
  74.  
  75. /*
  76.  * free_args
  77.  *
  78.  * free all memory allocated by _prepare_args()
  79.  *
  80.  * MUST be called after _set_args()
  81.  *
  82.  */
  83. void free_args(struct arglist *al)
  84. {
  85.     if (al)
  86.     {
  87.         del_dllist(al->al_list);
  88.         ufree(al);
  89.     }
  90. }
  91.  
  92.